using OpenAiMobile.Models;
using OpenAiMobile.ViewModels;

namespace OpenAiMobile.Views;

// ReSharper disable once RedundantExtendsListEntry
public partial class SearchPage : ContentPage
{
    public SearchPage(IContainerProvider container)
    {
        InitializeComponent();

        var viewModel = new SearchPageViewModel(container);
        viewModel.ItemAdded += OnItemAdded;
        BindingContext = viewModel;
    }

    private void OnItemAdded(MessageItem item)
    {
        MessageListControl.ScrollTo(item, ScrollToPosition.End, true);
    }
}